FROM golang:1.16-alpine3.13 AS build

WORKDIR /app

ADD . .

# 编译一个静态的go应用（在二进制构建中包含C语言依赖库）
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo .

CMD ["./demogo2"]

# FROM alpine:latest as certs
# RUN apk --update add ca-certificates

# FROM scratch AS prod
FROM alpine:3.13 AS prod
WORKDIR /app
EXPOSE 8080
HEALTHCHECK --interval=10s --timeout=3s --retries=3 CMD wget -qO- localhost:8080/demo/hello

# RUN mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2
# COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=build /app/demogo2 .

CMD ["./demogo2"]


